﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Pe.Petecos.Comercial.Presentacion.Core.Security
{
    public class AuthorizeFilter : AuthorizeAttribute
    {

        public override void OnAuthorization(AuthorizationContext filterContext)
        {

            if (HttpSessionContext.CurrentAccount() == null)
            {
                filterContext.Result = new RedirectResult(System.Web.Security.FormsAuthentication.LoginUrl);
                filterContext.Result.ExecuteResult(filterContext);
            }
            //else if (!service.ValidarAcceso(filterContext.HttpContext.Request.RawUrl))
            //{
            //    filterContext.Result = new HttpUnauthorizedResult();
            //    filterContext.Result.ExecuteResult(filterContext);
            //}

            //base.HandleUnauthorizedRequest(filterContext);
        }
    }
}
